package x;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;


/**
 * The map holds the data about game area. In this case its responsible
 * for both rendering the map and check collision against the grid cells
 * within.
 *
 * Our map is a simple WIDTHxHEIGHT grid containing value 0 to indicate
 * a clear cell and 1 to indicate a wall.
 *
 * @author Daniel Wheeler
 */
public class Map3 {
    //the ground for the map
        private Image floor;
        /** The value indicating a clear cell */
        private static final int CLEAR = 0;
        /** The value indicating a blocked cell */
        private static final int BLOCKED = 1;
        //cell for building door


        /** The width in grid cells of our map */
        private static final int WIDTH = 64;
        /** The height in grid cells of our map */
        private static final int HEIGHT = 48;

        /** The rendered size of the tile (in pixels) */
        public static final int TILE_SIZE = 10;

        /** The actual data for our map */
        private int[][] data = new int[WIDTH][HEIGHT];

        /**
         * Create a new map with some default contents
         */
        public Map3() {


/*----------------------------------------------level design----------------------*/

            //this makes vertical blocks and horizontal.......may change!
                for (int y=0;y<HEIGHT;y++)
                {
                        data[0][y] = BLOCKED;
                        data[WIDTH - 1][y] = BLOCKED;
                       for (int x=0;x<WIDTH;x++)
                   {

                     data[x][0] = BLOCKED;

                     data[x][HEIGHT - 1] = BLOCKED;

                     }
                }







        }

        /*---------------------------------------------------------------------------------*/
        /**
         * Render the map to the graphics context provided. The rendering
         * is just simple fill rectangles
         *
         */
        public void paint(Graphics2D g) {
                // loop through all the tiles in the map rendering them
                // based on whether they block or not
                for (int x=0;x<WIDTH;x++) {
                        for (int y=0;y<HEIGHT;y++) {

                                // so if the cell is blocks, draw a light grey block
                                // otherwise use a dark gray
                                g.setColor(Color.white);
                                if (data[x][y] == BLOCKED) {
                                        g.setColor(Color.black);
                                }

                                // draw the rectangle with a dark outline
                                g.fillRect(x*TILE_SIZE,y*TILE_SIZE,TILE_SIZE,TILE_SIZE);
                                g.setColor(g.getColor().darker());
                                g.drawRect(x*TILE_SIZE,y*TILE_SIZE,TILE_SIZE,TILE_SIZE);
                        }
                }





        }

        /**
         * Check if a particular location on the map is blocked. Note
         * that the x and y parameters are floating point numbers meaning
         * that we can be checking partially across a grid cell.
         *
         * @param x The x position to check for blocking
         * @param y The y position to check for blocking
         * @return True if the location is blocked
         */
        public boolean blocked(float x, float y)
        {
                // look up the right cell (based on simply rounding the floating
                // values) and check the value
                if (data[(int) x][(int) y] == BLOCKED)
                return data[(int) x][(int) y] == BLOCKED;

                else return false; //this should NEVER have to be called

        }



        //function place the buildings that you can go inside of buildings
        //returns the # of the building
        public int buildingChecker(float x, float y){

//convert the float numbers to ints
int x2 = (int) x;
int y2 = (int) y;

        int location = -1;

            if ((x2 == 15 || x2 == 14 )&& y2 == 20)
             location = 1; //location is upper left building, minigame 1

        //if (data[(int) x][(int) y] == BLOCKED)

        //if (data[(int) x][(int) y] == BLOCKED)
            return location;

 }


}

